﻿using System;
using System.Collections.Generic;
using System.ServiceModel.Description;

namespace XrmLibrary.Connections
{
    public class CrmConnectionManager
    {

        /// <summary>
        /// Stores CRM server configuration information.
        /// </summary>
        public class Configuration
        {
            public String ServerAddress;
            public String OrganizationName;
            public Uri DiscoveryUri;
            public Uri OrganizationUri;
            public Uri HomeRealmUri = null;
            public ClientCredentials DeviceCredentials = null;
            public ClientCredentials Credentials = null;
            public AuthenticationType EndpointType;
        }

        public List<Configuration> Configurations = null;

        private readonly Configuration _config = new Configuration();

        public virtual Configuration GetServerConfiguration(String crmOrganizationUrl, Uri homeRealmUri, ClientCredentials credentials, ClientCredentials deviceCredentials)
        {
            _config.OrganizationUri = new Uri(crmOrganizationUrl);
            _config.Credentials = credentials;
            _config.HomeRealmUri = homeRealmUri;
            _config.DeviceCredentials = deviceCredentials;
            return _config;
        }
    }

    public enum AuthenticationType
    {
        AD,
        IFD,
        Passport,
        OSDP
    }
}
